package com.bw.goods.mvvm.model;

import com.bw.mvvm_comom.entity.BaseEntity;
import com.bw.mvvm_comom.model.BaseModel;
import com.bw.mvvm_comom.network.HttpEnum;
import com.bw.mvvm_comom.network.HttpFactory;

import java.util.ArrayList;
import java.util.HashMap;

import io.reactivex.Observable;

public class CategoryModel extends BaseModel {
    public Observable<BaseEntity> requestCategory(HashMap<String,Object> ...maps){
        ArrayList<Observable<BaseEntity>> list = new ArrayList<>();
        for (int i = 0; i < maps.length; i++) {
            Observable<BaseEntity> observable = null;
            HashMap<String,Object> map = maps[i];
            int code = (int) map.remove("code");
            map.remove("code");
          if (code == 1001){
             list.add(observable = changeFunc(HttpFactory.create(HttpEnum.TokenSign)
                     .getRetrofit().create(Api.class)
                     .requsetCategory(createBody(map))));
          }else if (code == 1002){
              list.add(observable = changeFunc(HttpFactory.create(HttpEnum.TokenSign)
                      .getRetrofit().create(Api.class)
                      .requsetValueCategory(createBody(map))));
          }

            list.add(observable);
        }
        return Observable.merge(list);
    }

}
